package com.dao;

import com.entity.ConfigEntity;
import com.ex.MyException;
import top.appx.easysql.BaseDatabase;
import top.appx.easysql.Restrain;
import top.appx.espring.annotation.Source;


@Source
public class ConfigDao extends BaseDao<ConfigEntity>{
    @Override
    public void modify(ConfigEntity configEntity){
        BaseDatabase db = getDatabase();
        try{
            db.beginTrans();
            db.modify(configEntity);
            if(db.total(entityClass, Restrain.eq("name",configEntity.getName()))>1){
                throw new MyException("名称不能重复");
            }
            db.commitTrans();
        }catch (Exception ex){
            db.rollback();
            throw (RuntimeException)ex;
        }finally {
            db.close();
        }

    }

}
